<template>
    <div class="sidebar">
        <p v-for="(item,index) in title" :key="index" :class="{active:cur==item.name}"
         @click="changeCurMenu(item.to),changeCur(item.name)">
            {{item.name}}
        </p>
    </div>
</template>

<script>
import {mapMutations} from "vuex"
export default {
    data() {
        return {
            title:[],
            cur:"热门",
            info:[]
        }
    },mounted() {
         this.$axios.get("../../static/json/menu.json").then(res=>{
           this.title=res.data.allInfo.menuList
        //    console.log(this.title);
        })
    },methods: {
        ...mapMutations(["changeCurMenu"]),
        changeCur(item){
            console.log(item);
            this.cur = item;
        }
    },
}
</script>

<style scoped lang="less">
</style>